﻿@using JavaDevToys.Rcl.Pages
@inherits LayoutComponentBase

<MApp>
    <MAppBar App>
        <MSpacer></MSpacer>
        <MIcon Size=20 Class="ml-5" Color="neutral-lighten-3" OnClick="() => _showSetting = true">mdi-cog-outline</MIcon>
    </MAppBar>
    <MNavigationDrawer App Permanent>
        @* ExpandOnHover *@
        <MList Routable Nav>
            @foreach (var navItem in _navItems)
            {
                if (navItem.Children?.Any() is true)
                {
                    <MListGroup NoAction Group="@navItem.Group">
                        <ActivatorContent>
                            <MListItemIcon>
                                <MIcon>@navItem.Icon</MIcon>
                            </MListItemIcon>
                            <MListItemContent>
                                <MListItemTitle>@navItem.Name</MListItemTitle>
                            </MListItemContent>
                        </ActivatorContent>
                        <ChildContent>
                            @foreach (var subNavItem in navItem.Children)
                            {
                                <MListItem Href="@subNavItem.Url"
                                           ActiveClass="primary--text"
                                           Exact="@subNavItem.Exact"
                                           MatchPattern="@subNavItem.MatchPattern">
                                    <MListItemContent>
                                        <MListItemTitle>@subNavItem.Name</MListItemTitle>
                                    </MListItemContent>
                                </MListItem>
                            }
                        </ChildContent>
                    </MListGroup>
                }
                else
                {
                    <MListItem Href="@navItem.Url"
                               ActiveClass="primary--text"
                               Exact="@navItem.Exact"
                               MatchPattern="@navItem.MatchPattern">
                        <MListItemContent>
                            <MListItemTitle>@navItem.Name</MListItemTitle>
                        </MListItemContent>
                    </MListItem>
                }
            }
        </MList>
    </MNavigationDrawer>

    <MMain>
        <MContainer>
            @Body
        </MContainer>
    </MMain>
    <Settings @bind-Show=_showSetting />
</MApp>

